import React from 'react';
import {NavLink} from "react-router-dom";
import {Menu} from 'antd';
import menus from './menus';
import {isVoid} from "../platform/GlobalUtils/Globaling";
const {Item, SubMenu}=Menu;
function PageNavLink(){
    return(
        <Menu mode="inline" defaultSelectedKeys={[menus[0].key]}> {/**  defaultOpenKeys={['sub1']} **/}
            {/** 三级以上目录时 **/}
            {menuFun(menus)}
        </Menu>
    )
}
function menuFun(menuChilds){
    return menuChilds.map((list)=>{
        if(!isVoid(list.childs)){
            return (
                <SubMenu key={list.key} title={list.name}>
                    {menuFun(list.childs)}
                </SubMenu>
            )
        }else{
            return <Item key={list.key}><NavLink to={list.url}>{list.name}</NavLink></Item>
        }
    })
}

export default PageNavLink;
